var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, o, n) {
    var s, l = arguments.length, r = l < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n); else for (var c = e.length - 1; 0 <= c; c--) (s = e[c]) && (r = (l < 3 ? s(r) : 3 < l ? s(t, o, r) : s(t, o)) || r);
    return 3 < l && r && Object.defineProperty(t, o, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = cc._decorator, c = s.ccclass, l = s.property, d = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.skeleton = null, e.path = null, e;
    }
    return i(e, t), e.prototype.start = function() {}, e.prototype.init = function(n) {
        var s = this;
        return new Promise(function(t, o) {
            s.skeleton.node.setPosition(n.pos), s.skeleton.node.setParent(n.root), s.path != n.url && (s.path = n.url, 
            r.default.getInstance().loadRes({
                url: n.url,
                type: sp.SkeletonData
            }).then(function(e) {
                try {
                    s.path == n.url ? (s.skeleton.skeletonData = e, t(s.skeleton)) : o();
                } catch (e) {
                    o();
                }
            }).catch(function() {
                o();
            }));
        });
    }, e.prototype.reset = function() {
        this.skeleton && (this.skeleton.setCompleteListener(null), this.skeleton.skeletonData && (this.skeleton.skeletonData = null), 
        this.skeleton.node && (this.skeleton.unscheduleAllCallbacks(), cc.Tween.stopAllByTarget(this.skeleton.node), 
        this.skeleton.node.removeFromParent(), this.skeleton.node.setScale(1), this.skeleton.node.color = cc.Color.WHITE, 
        this.skeleton.node.angle = 0, this.skeleton.node.opacity = 255, this.skeleton.node.zIndex = 0, 
        this.skeleton.timeScale = 1)), this.path = null;
    }, a([ l(sp.Skeleton) ], e.prototype, "skeleton", void 0), a([ c ], e);
}(cc.Component);

n.default = d;